package com.example.aop.tester;

import com.example.aop.anno.MyAnno;
import com.example.common.utils.Statistics;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@Slf4j
@Lazy
@Component
public class MyAopInterfaceTesterImpl implements MyAopInterfaceTester, DisposableBean {

    /**
     * 接口类不能私有构造？ 还是AOP的原因? 是AOP的原因
     */
    public MyAopInterfaceTesterImpl() {
        Statistics.logInfo(log);
    }

    @MyAnno
    @Override
    public MyReturn myMethod(MyArgs myArgs) {
        MyReturn myReturn = new MyReturn();
        BeanUtils.copyProperties(myArgs, myReturn);
        return myReturn;
    }

    @Override
    public void destroy() throws Exception {
        Statistics.logInfo(log, "destroy", "");
    }
}
